local chuanjiao = fk.CreateSkill {
  name = "lingling__chuanjiao",
}

Fk:loadTranslationTable {
  ["lingling__chuanjiao"] = "传教",
  [":lingling__chuanjiao"] = "游戏开始时，你可以令至多两名角色获得技能〖神功护体〗。",

  ["#lingling__chuanjiao-choose"] = "传教：令至多两名角色获得“神功护体”",
}

chuanjiao:addEffect(fk.GameStart, {
  anim_type = "support",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(chuanjiao.name) and
        table.find(player.room.alive_players, function(p)
          return not p:hasSkill("lingling__shengonghuti", true)
        end)
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local targets = table.filter(room.alive_players, function(p)
      return not p:hasSkill("lingling__shengonghuti", true)
    end)
    local tos = room:askToChoosePlayers(player, {
      min_num = 1,
      max_num = 2,
      targets = targets,
      skill_name = chuanjiao.name,
      prompt = "#lingling__chuanjiao-choose",
      cancelable = true,
    })
    if #tos > 0 then
      room:sortByAction(tos)
      event:setCostData(self, { tos = tos })
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    for _, p in ipairs(event:getCostData(self).tos) do
      room:handleAddLoseSkills(p, "lingling__shengonghuti")
    end
  end,
})

return chuanjiao
